﻿using UnityEngine;

namespace DL
{
    public class GameBlackboardController : MonoBehaviour
    {
        [SerializeField]
        private GameBlackBoardData gameBlackBoardData;
        private readonly GameBlackboard m_GameBlackboard = new();
        private readonly Arbiter m_Arbiter = new();

        public GameBlackboard GameBlackboard() => m_GameBlackboard;
        private void Awake()
        {
            gameBlackBoardData.SetValuesOnGameBlackBoard(m_GameBlackboard);
            m_GameBlackboard.Debug();
        }

        public void RegisterExpert(IExpert expert) => m_Arbiter.RegisterExpert(expert);

        private void Update()
        {
            foreach (var action in m_Arbiter.GameBlackboardIteration(m_GameBlackboard))
            {
                action?.Invoke();
            }
            
        }
    }


}